package top.fullj.bean;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * @author bruce.wu
 * @since 2021/6/24 15:24
 */
class GsonCodec implements JsonCodec {

    private final Gson GSON = new GsonBuilder().create();

    @Override
    public String encode(Object value) {
        return GSON.toJson(value);
    }

    @Override
    public <T> T decode(String jsonStr, Class<T> type) {
        return GSON.fromJson(jsonStr, type);
    }
}
